<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld"%>
<%@ taglib prefix="spring" uri="/WEB-INF/tlds/spring.tld"%>
<c:set var="BasePath" value="${pageContext.request.contextPath}"></c:set>
<c:set var="Plugins" value="${pageContext.request.contextPath}/res/plugins"></c:set>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>商品列表</title>
<link href="${Plugins}/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<link href="${Plugins}/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
<script src="${Plugins}/jquery/jquery-1.3.2.min.js"	type="text/javascript"></script>
<script src="${Plugins}/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script type="text/javascript" src="${BasePath}/res/js/ligerCommon.js"></script>

<style type="text/css">
#searchbar{
   margin-bottom: 10px;
   margin-left:15px;
  }
  .navbar {
		height: 20px;
		border-bottom: #E6E6E6 solid 1px;
		line-height: 20px;
	}
.l-button-search {
	width: 50px;
	margin-left: 10px;
	padding-bottom: 2px;
	display: inline;
}
</style>
</head>

<body style="padding:6px; overflow:hidden;">
<div class="navbar">
		<span>您当前的位置：商品管理 &gt</span>
		货品批次入库记录列表
</div><br>
<form action="#"  name="queryForm" id="queryForm" method="POST">
		仓库编码：<input type="text" id="whCode" name="whCode" size="18" maxLength="40" value="${pbir.whCode }">&nbsp;&nbsp;&nbsp;&nbsp;
		单号：<input type="text" id="orderNo" name="orderNo" size="18" maxLength="40" value="${pbir.orderNo }">&nbsp;&nbsp;&nbsp;&nbsp;
		货品编号：<input type="text" id="prodNo" name="prodNo" size="18" maxLength="40" value="${pbir.prodNo }"><br><br>
    	出入库类型:<select id="moduleCode" name="moduleCode">
				    <option value=""  <c:if test="${pbir.moduleCode == ''}">selected</c:if>>请选择</option>
				    <option value="0001"  <c:if test="${pbir.moduleCode == '0001'}">selected</c:if>>其他入库</option>
				   	<option value="0002"  <c:if test="${pbir.moduleCode == '0002'}">selected</c:if>>其他出库</option>
					<option value="0003"  <c:if test="${pbir.moduleCode == '0003'}">selected</c:if>>采购入库</option> 
					<%-- <option value="0004"  <c:if test="${pbir.moduleCode == '0004'}">selected</c:if>>库内盘点</option> 
					<option value="0005"  <c:if test="${pbir.moduleCode == '0005'}">selected</c:if>>调拨入库</option> 
					<option value="0006"  <c:if test="${pbir.moduleCode == '0006'}">selected</c:if>>调拨出库</option>  --%>
					<option value="0007"  <c:if test="${pbir.moduleCode == '0007'}">selected</c:if>>配货单出库</option> 
					<option value="0008"  <c:if test="${pbir.moduleCode == '0008'}">selected</c:if>>销售退货入库</option> 
					<option value="0009"  <c:if test="${pbir.moduleCode == '0009'}">selected</c:if>>采购退货出库</option> 
				   </select>&nbsp;&nbsp;&nbsp;&nbsp;
		<%-- 是否已抓取:<select id="isGrab" name="isGrab">
				    <option value=""  <c:if test="${icVo.isGrab == ''}">selected</c:if>>请选择</option>
				    <option value="0"  <c:if test="${icVo.isGrab == '0'}">selected</c:if>>未抓取</option>
				   	<option value="1"  <c:if test="${icVo.isGrab == '1'}">selected</c:if>>已抓取</option>
				   </select>&nbsp;&nbsp;&nbsp;&nbsp; --%>
		<input type="submit" value="查询" class="l-button-search"  >&nbsp;&nbsp;&nbsp;&nbsp;<input  type="button" id="resetButton" value="重置" class="l-button-search" >
	</form><br>
<div id="maingrid" style="margin:0; padding:0"></div>
  <div style="display:none;">
  <!-- 展示列表数据  -->
</div><br><br>

	<script>
	var grid = null;
    $(function () {
    	$('#resetButton').click(function() {
        	$('#whCode').val('');
        	$('#orderNo').val('');
        	$('#prodNo').val('');
        	$("select").find("option[value='']").attr("selected","true");  
        });
    	grid = $("#maingrid").ligerGrid({
            columns: [
            { display: '仓库编码', name: 'whCode',align: 'left', width: '8%' },
            { display: '单号', name: 'orderNo', width: '12%' },
            { display: '入库单号', name: 'inNo', width: '12%' },
            { display: '供应商编码 ', name: 'suppNo', width: '12%' },
            { display: '出入库类型', name: 'moduleCode', width: '10%', render: function(rowdata, rowindex, value) {
            	var text = '';
            	if (rowdata.moduleCode == '0001') {
            		text = '其他入库';
            	} else if (rowdata.moduleCode == '0002') {
            		text = '其他出库';
            	} else if (rowdata.moduleCode == '0003') {
            		text = '采购入库';
            	} else if (rowdata.moduleCode == '0004') {
            		text = '库内盘点';
            	} else if (rowdata.moduleCode == '0005') {
            		text = '调拨入库';
            	} else if (rowdata.moduleCode == '0006') {
            		text = '调拨出库';
            	} else if (rowdata.moduleCode == '0007') {
            		text = '配货单出库';
            	} else if (rowdata.moduleCode == '0008') {
            		text = '销售退货入库';
            	} else if (rowdata.moduleCode == '0009') {
            		text = '采购退货出库';
            	}
            	return text;
            } },
            { display: '货品编号', name: 'prodNo', width:'10%' },
            { display: '入库单价', name: 'prodPrice', width:'10%' },
            { display: '变动单价', name: 'floatPrice', width:'10%', type: 'float', editor: { type: 'float'}, render: function(rowdata, rowindex, value){
  	  			if (isNaN(rowdata.inAmount)) rowdata.inAmount = 0;
  	  			if (isNaN(rowdata.prodPrice)) rowdata.prodPrice = 0.00;
  	  			if (isNaN(rowdata.floatPrice)) rowdata.floatPrice = 0.00;
  	  			if (isNaN(value)) value = 0.00;
            	rowdata.factTotalPrice = (rowdata.prodPrice + rowdata.floatPrice) * rowdata.inAmount;
            	return String(value);
            } },
            { display: '实际总价', name: 'factTotalPrice', width:'10%', render: function(rowdata, rowindex, value) {
            	return rowdata.factTotalPrice.toFixed(2);
            } },
            { display: '入库数量', name: 'inAmount', width:'10%' },
            { display: '剩余数量', name: 'leftAmount',align: 'left', width:'10%' },
            { display: '入库时间', name: 'inTime', width:'15%' }
            /* { display: '是否已抓取', name: 'isGrab', width:'10%', render: function(rowdata, rowindex, value) {
            	var text = '';
            	if (rowdata.isGrab == '1') {
            		text = '已抓取';
            	} else {
            		text = '未抓取';
            	}
            	return text;
            } } */
            ], 
            pageSize:30,
            enabledEdit: true,
            onAfterEdit: f_onAfterEdit,
            width: '100%',
            height: '100%',
            dataType: 'server', 
            dataAction: 'server',
            pagesizeParmName: 'pageSize',
            parms: [
                    {name: "whCode", value:$("#whCode").val()},
                    {name: "orderNo", value:$("#orderNo").val()},
                    {name: "prodNo", value:$("#prodNo").val()},
                    {name: "moduleCode", value:$("#moduleCode").val()}
            	],
            url: "ajaxToProdBatchInRecord.do",
        });
   	});
    
    function f_onAfterEdit(rowdata, rowindex, value) {
    	$.ajax({
			type: "POST",
			async: false,
		    url: 'updateFloatPrice.do',
		    data: {id: rowdata.record.id, floatPrice: rowdata.record.floatPrice},
		    success: function (data) {
		    	if (data != 'success') {
		    		$.ligerDialog.warn('变动单价更新失败');
		    	}
		    }
		});
    }
    </script>
	
</body>
</html>